package com.hellogood.yaohuo.server.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.hellogood.yaohuo.server.db.DBHelper;
import com.hellogood.yaohuo.shared.entity.PdDetail;

public class PdDetailDAO extends DBHelper {
	Logger log = Logger.getLogger(this.getClass());
	@Override
	public List<?> initializeObject(ResultSet rs) throws SQLException {
		List<PdDetail> pdDetailList = new ArrayList<PdDetail>();
		if (rs != null) {
			while (rs.next()) {
				PdDetail pdDetail = new PdDetail();				
				pdDetail.setPdBillNo(rs.getString("pdBillNo"));
				pdDetail.setPluCode(rs.getString("pluCode"));
				pdDetail.setPluName(rs.getString("pluName"));
				pdDetail.setBarCode(rs.getString("barCode"));
				pdDetail.setBra(rs.getString("bra"));
				pdDetail.setColor(rs.getString("color"));
				pdDetail.setSize(rs.getString("CSize"));
				pdDetail.setZmCounts(rs.getInt("zmCounts"));
				pdDetail.setSjCounts(rs.getInt("sjCounts"));
				pdDetail.setYkCounts(rs.getInt("ykCounts"));
				pdDetail.setjPrice(rs.getBigDecimal("jPrice"));
				pdDetail.setNetPrice(rs.getBigDecimal("netPrice"));
				pdDetail.setPrice(rs.getBigDecimal("price"));				
				pdDetail.setZmCost(rs.getBigDecimal("zmCost"));
				pdDetail.setZmNetCost(rs.getBigDecimal("zmNetCost"));
				pdDetail.setZmTotal(rs.getBigDecimal("zmTotal"));
				pdDetail.setSjCost(rs.getBigDecimal("sjCost"));
				pdDetail.setSjNetCost(rs.getBigDecimal("sjNetCost"));
				pdDetail.setSjTotal(rs.getBigDecimal("sjTotal"));
				pdDetail.setYkCost(rs.getBigDecimal("ykCost"));
				pdDetail.setYkNetCost(rs.getBigDecimal("ykNetCost"));
				pdDetail.setYkTotal(rs.getBigDecimal("ykTotal"));
				pdDetail.setTimeMark(rs.getString("timeMark"));
				pdDetail.setRzDate(rs.getString("rzDate"));
				pdDetail.setRemark(rs.getString("remark"));
				pdDetailList.add(pdDetail);
			}
		}
		return pdDetailList;
	}

	@SuppressWarnings("unchecked")
	public List<PdDetail> getDetailByBillNo(String billNo){
		List<PdDetail> list = new ArrayList<PdDetail>();
		String sql = "SELECT * FROM pdDetail WHERE pdBillNo = '" +billNo+"'";
		list = (List<PdDetail>) super.query(sql);
		return list;
	}
	
	
}
